package msu.ml.data;

import msu.ml.core.*;
import weka.core.*;
import weka.classifiers.evaluation.*;

/**
 *
 * @author Reginald M Mead
 * @version 1.0
 */
public class ConfusionMatrixPostProcessor extends DataPostProcessorAdapter
{
   private ConfusionMatrix matrix;

   public ConfusionMatrixPostProcessor() 
   {
      matrix = new ConfusionMatrix(new String [] {
            "non", "bio" });
   }

   public void process(Instance inst, double[] dist)
   {
      try
      {
         matrix.addPrediction(new NominalPrediction(inst.classValue(), dist));
      }
      catch(Exception e)
      {
         e.printStackTrace();
      }
   }

   public void endExperiment()
   {
      System.out.println(matrix);
      System.out.println(String.format("Pulse Volume Accuracy = %1$.2f", 
               (matrix.correct() / matrix.total())));
   }

}
